Skip to content

Conversation

@revmischa
Copy link
Member

Fixes parser rejecting valid HLSL like float2 var = (float2(x,y)) * scalar with "expected ';'" errors.

When parsing a parenthesized expression, ParseBinaryExpression() would break from its loop before consuming the closing paren. The subsequent binary operator was never seen because the return statement consumed the ) and exited immediately.

The fix moves end-char consumption into the else block and checks for a following binary operator after consuming the paren, continuing the loop if one is found.

Credit to @rootnotez for the detailed analysis and test cases that identified the root cause.

Fixes #940

The parser rejected valid HLSL like `float2 var = (float2(x,y)) * scalar`
with "expected ';'" errors. When parsing a parenthesized expression, the
loop would break before consuming the closing paren, so subsequent binary
operators were never seen.

Moves end-char consumption into the else block and checks for operators
after consuming the paren, continuing the loop if one is found.

Fixes #940

This comment was marked as spam.

Covers the fix for issue #940 with tests for:
- Parenthesized constructor with binary operators
- Double-nested parentheses
- Both operands parenthesized
- Chained operators after parens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DEV BUG] HLSLParser: Expression in declaration causes parsing error

1 participant